let timg = document.querySelector("#timg")
let timgX, timgY, scrollX, scrollY
let evt = {
    getEvent: (e) => {
        return e || window.event
    },
    getClientX: (e) => {
        return evt.getEvent(e).clientX
    },
    getClientY: (e) => {
        return evt.getEvent(e).clientY
    },
    getScrollLeft: () => {
        return window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0
    },
    getScrollTop: () => {
        return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0
    },
    getPageX: (e) => {
        return evt.getEvent(e).pageX ? evt.getEvent(e).pageX : evt.getClientX(e) + evt.getScrollLeft()
    },
    getPageY: (e) => {
        return evt.getEvent(e).pageY ? evt.getEvent(e).pageY : evt.getClientY(e) + evt.getScrollTop()
    }
}
document.addEventListener("mousemove", function (e) {
    if (evt.getPageX(e) + timg.clientWidth + 20 >= window.innerWidth) {
        timg.style.left = evt.getPageX(e) - timg.clientWidth + "px"
    } else {
        timg.style.left = evt.getPageX(e) + "px"
    }
    timg.style.top = evt.getPageY(e) + "px"
    timgX = parseFloat(timg.style.left)
    timgY = parseFloat(timg.style.top)
    scrollX = evt.getScrollLeft()
    scrollY = evt.getScrollTop()
}, false)
document.addEventListener("scroll", function (e) {
    let dx = scrollX >= evt.getScrollLeft() ? -(scrollX - evt.getScrollLeft()) : evt.getScrollLeft() - scrollX
    let dy = scrollY >= evt.getScrollTop() ? -(scrollY - evt.getScrollTop()) : evt.getScrollTop() - scrollY
    timg.style.left = timgX + dx + "px"
    timg.style.top = timgY + dy + "px"
}, false)


let iconbar = document.querySelector(".icon-bar")
let nav = document.querySelector(".nav")
iconbar.onclick = function () {
    nav.style.display = nav.style.display == "" ? "block" : ""
}
window.onresize = function () {
    nav.style.display = ""
}

let down = document.querySelector("#download")
down.addEventListener("click",function () {
    window.open("./Title.pdf")
})